package com.example.springdemo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletContext;

/**
 * @description:
 * @author: dengPing.xu
 * @date: 2022-04-02
 */
@RestController
public class HelloController {

    @Autowired
    ServletContext servletContext;

    @GetMapping("/hello/{id}")
    public String getHello(String name, @PathVariable String id){
        return "hello，" + id + name + "，今年你已经" + servletContext.getAttribute("age") + "岁了，要乖哦。";
    }

}
